/*********************************************************************
 * INCLUDES
 */

/*********************************************************************
 * CONSTANTS
 */
#define EINK_CFG_UPDATE            0x0001
#define EINK_UPDATE_TIME            0x0002
#define MESU_HT                     0x0004
#define EINK_PROCESS             	0x0008
#define MESU_BAT             		0x0010
/*********************************************************************
 * MACROS
 */
enum {
	cmd_partDisplayThreshold,
	cmd_tempSymbol,
	cmd_mainDisplay,
	cmd_timeZone,
	cmd_tempThd,
	cmd_hyThd,
};

enum {
	eink_idle,
	eink_init,
	eink_allBalck,
	eink_allWhite,
	eink_update,
	eink_sleep,
	eink_pFlash,
	eink_fFlah,
};

enum {
	maindis_time,
	maindis_temp,
	maindis_humi,
};

enum {
	INT_RX8025 = 1
};

typedef struct {
	uint8_t partDisplayThreshold;
	uint8_t tempSymbol;
	uint8_t mainDisplay;
	int8 timeZone;
	uint8_t tempThd;
	uint8_t hyThd;

} FlashSavedCFG_t;

typedef struct {
	uint8_t fullDisplayFlag;
	uint8_t partDisplayCnt;
	uint8_t einkInitFlag;
	uint16_t temp100Old;
	uint16_t humi100Old;
	uint32_t timestamp;
	uint8_t einkIdx;

} einkStatus_t;

#define PDTHD_DEFAULT	20
#define TEMPSYMBOL_DEFAULT	0
#define MAINDIS_DEFAULT	0
#define TIMEZONE_DEFAULT	8
#define TEMPTHD_DEFAULT	3
#define HUMITHD_DEFAULT	2

#define HT_INTERVAL		20//second
#define BAT_INTERVAL		20*60//second
/*********************************************************************
 * FUNCTIONS
 */
extern einkStatus_t einkStatus;
extern FlashSavedCFG_t flashSavedCFG;
/*
 * Task Initialization for the BLE Broadcaster Application
 */
extern void Eink_Init(void);

/*
 * Task Event Processor for the BLE Broadcaster Application
 */
extern uint16_t Eink_ProcessEvent(uint8_t task_id, uint16_t events);

extern void timeIntHandler(void);
extern void einkSetTime(uint32_t timeStamp);
extern void einkSetCfg(uint8_t cmd, uint8_t data);
extern void einkBLEConnected(uint8_t BLEStatus);
